<script>
export default {

  data() {
    return {
      arr: [],
      show: false,
      guaming: '',
      showProblem: false, // 是否显示问题
      problem: {},
      screenHeight: '70vh'
    }
  },
  created() {
    // console.log(uni.getSystemInfoSync())
    // const systemInfo = uni.getSystemInfoSync();
    // this.screenHeight =( systemInfo.windowHeight - systemInfo.screenTop) + 'px'
  },
  methods: {
    openModal(guaming, arr) {
      this.showProblem = true
      this.show = true
      this.guaming = guaming;
      this.arr = this.getProblemAndChoose(arr)
      console.log(arr)
    },
    closeModal() {
      this.show = false
      this.guaming = '';
      this.arr = []
      this.showProblem = false
    },
    getProblemAndChoose(arr) {
      // 找到title为卦象的数据保存并删除
      this.problem = arr.find((item) => item.title === '卦曰')
      return arr.filter(item => item.title !== "卦曰")
    },
    // 解卦
    changeShowProblem() {
      this.showProblem = !this.showProblem
    }
  }
}

</script>

<template>
  <view v-if="show" class="juan-zou">
    <view v-if="showProblem" class="juan-box juan-box2">
      <image class="juan-img" src="../../../static/imgs/juan.png"></image>
      <view class="juan-content">
        <view class="tit">
          卦曰
        </view>

        <view class="desc">{{ problem.desc }}</view>

        <image class="juan-people" src="../../../static/imgs/people.png"></image>
        <view class="juan-btn" @click="changeShowProblem">解卦</view>
      </view>
      <image class="juan-img" src="../../../static/imgs/juan.png"></image>

    </view>
    <view v-if="!showProblem" :style="{height:screenHeight}" class="juan-box">

      <image class="juan-img" src="../../../static/imgs/juan.png"></image>
      <view class="juan-content">
        <view class="tit">
          每日一签
        </view>

        <view class="today-do">
          <view v-for="ls in arr" :key="ls.id" class="do-item">
            <view class="title">{{ ls.title }}</view>
            <view class="desc">{{ ls.desc }}</view>
          </view>
        </view>

        <image class="juan-people" src="../../../static/imgs/people.png"></image>
        <image class="close" src="../../../static/imgs/close.png" @click="closeModal"></image>

      </view>
      <image class="juan-img" src="../../../static/imgs/juan.png"></image>
    </view>
  </view>
</template>

<style lang="scss" scoped>
.juan-zou {
  position: fixed;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, .5);
  z-index: 99;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  .juan-box {
    position: relative;
    width: 80%;
    height: 90vh;

    &.juan-box2 {
      height: 30vh;
      color: #9C8F6F;
      font-size: 20rpx;

      .juan-content {
        background: #FFEFC9;
        padding: 0 20rpx;
      }

      .desc {
        margin: 20rpx 0;
      }

      .juan-btn {
        margin: 40rpx auto;
        border: 1px solid #9C8F6F;
        font-size: 26rpx;
        border-radius: 30rpx;
        padding: 10rpx 35rpx;
        width: 120rpx;
        text-align: center;
        white-space: nowrap;
      }
    }

    //border: 1px solid red;
  }

  .close {
    width: 140rpx;
    height: 35rpx;
    //position: absolute;
    //right: -10rpx;
    //top: -10rpx;
    display: block;
    margin: 0 auto;
  }

  .juan-img {
    width: 100%;
    height: 20rpx;
    position: relative;
    z-index: 1;
  }

  @keyframes heightAdd {
    0% {
      height: 0;
    }
    100% {
      height: 95%;
    }
  }

  @keyframes showImg {
    0% {
      opacity: 0;
    }
    100% {
      opacity: .4;
    }
  }

  .juan-content {
    //background: url("../../../static/imgs/juan-bg.png") no-repeat;
    //background-size: 100% 100%;
    background: #FFEFC9;
    border: 1px solid #FFEFC9;
    width: 90%;
    margin: -10rpx auto;
    height: 95%;
    overflow-y: scroll;
    overflow-x: hidden;
    animation: heightAdd 1s linear;
    position: relative;
    z-index: 1;
    padding-bottom: 20rpx;

    .juan-people {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      top: 0%;
      width: 328rpx;
      height: 213rpx;
      z-index: -1;
      opacity: 0.4;
      animation: showImg 2s cubic-bezier(0.340, 0.530, 0.850, 0.485);

    }

    .tit {
      font-size: 35rpx;
      font-weight: bold;
      text-align: center;
      color: #A38633;
      margin-top: 60rpx;
      animation: showImg 1s cubic-bezier(0.340, 0.530, 0.850, 0.485);

    }

    .today-do {
      font-size: 24rpx;
      line-height: 16px;
      column-count: 2;
      column-gap: 0;
      color: #9C8F6F;
      position: relative;
      z-index: 777;
      width: 100%;
      padding: 40rpx 30rpx;
      margin-top: 40rpx;

      .do-item {
        margin-bottom: 12px;
        padding-right: 24px;
      }

      .title {
        font-size: 12px;
        color: #c09351;
        height: 24px;
      }
    }

  }
}
</style>
